const express = require("express")
const router = express.Router()
const { query } = require("@/db/query.js")
import { success, error } from "@/utils/index"
// import 
router.get("/login", async (req, res) => {
  const { id } = req.query
  const sql = "select * from user where id = " + id
  try {
    const result = await query(sql)
    const data = {}
    if (result.length > 0) {
      data.id = result[0].id
      data.name = result[0].name
      data.flag = result[0].flag
    }
    res.send({...success,data})
  } catch (err) {
    res.send(error)
  }
})

router.get("/doLogin", (req, res) => {
  res.send({
    ...success,
    data:{
      msg:"doLogin"
    }
  })
})
module.exports = router